<template>
  <div>
    <x-header
      title="报餐汇总查询"
    >
    </x-header>
    <group gutter="0">
      <datetime
        v-model="startTime"
        title="开始日期"
        format="YYYY-MM-DD"
      ></datetime>
      <datetime
        v-model="endTime"
        title="结束日期"
        format="YYYY-MM-DD"
      ></datetime>
    </group>
    <x-button type="primary" :link="{name:'allSearchResult', query: {startTime: startTime, endTime: endTime}}">查询</x-button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      startTime: '2019-10-17',
      endTime: '2019-10-21'
    }
  },
  created () {
    let date = new Date()
    let nextOne = (date.getDay() - 8) * -1 // 下周一
    date.setDate(date.getDate() + nextOne) // 下周一
    this.startTime = date.getFullYear() + '-' + this.zero((date.getMonth() + 1)) + '-' + this.zero(date.getDate())
    date.setDate(date.getDate() + 6) // 下周日
    this.endTime = date.getFullYear() + '-' + this.zero((date.getMonth() + 1)) + '-' + this.zero(date.getDate())
  },
  methods: {
    zero (val) {
      return val < 10 ? '0' + val : val
    }
  }
}
</script>
<style scoped>
</style>
